<template>
	<view class="content">
		<view class="info-list" v-for="item in list" :key="item.id" v-if="item.represent.length>0">
			<view class="title FangZhengHanZhenGuangBiaoJianTi">{{item.name}}</view>
			<view class="info-block">
				<view class="info-item" v-for="item1 in item.represent" :key="item1.id"
					@click="navigate('/pages/representative/details?id='+item1.id)">
					<image :src="item1.photo" class="info-img"></image>
					<view class="name-item">
						<view class="name">{{item1.name}}</view>
						<view class="type">{{item1.position}}</view>
						<view class="btn">有事您说话</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		representList
	} from '@/api/represent.js'
	export default {
		data() {
			return {
				list: []
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			getList() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				representList().then(res => {
					this.list = res;
				})
			}
		},
		onLoad() {
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #F7F7F9;
		padding: 30rpx;
		min-height: 100vh;

		.info-list {
			background-color: #fff;
			border-radius: 30rpx;
			padding: 20rpx;
			margin-bottom: 20rpx;

			.title {
				font-size: 34rpx;
				color: #BB151C;
				margin-bottom: 30rpx;
				margin-top: 20rpx;
			}

			.info-block {
				width: 100%;
				display: flex;
				align-items: center;
				flex-wrap: wrap;
				justify-content: space-between;

				.info-item {
					width: calc((100% - 20rpx) /2);
					padding: 20rpx;
					background-color: #FEF7ED;
					border-radius: 30rpx;
					display: flex;
					margin-bottom: 20rpx;

					.info-img {
						width: 120rpx;
						height: 170rpx;
						margin-right: 10rpx;
						border-radius: 16rpx;
					}

					.name-item {
						width: calc(100% - 130rpx);

						.name {
							font-size: 30rpx;
							font-weight: bold;
							margin-bottom: 10rpx;
						}

						.type {
							color: #767676;
							font-size: 24rpx;
							margin-bottom: 20rpx;
							word-break: break-all;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							/* 超出几行省略 */
							overflow: hidden;
						}

						.btn {
							background-color: #BB151C;
							font-size: 20rpx;
							color: #fff;
							width: 130rpx;
							height: 44rpx;
							border-radius: 30rpx;
							display: flex;
							align-items: center;
							justify-content: center;
						}
					}
				}
			}
		}
	}
</style>